package com.tree;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;

/**
 * @Author:hanguanglei
 * @Description:
 * @Date: Created in 2020-10-07 13:52
 * @Modified By:
 */

public class Demo {

    public static void main(String[] args) {
        String dataFilePath = "C:\\Users\\Administrator\\Desktop\\tree_of_virus_input.txt";

        LCATool lcaTool=new LCATool(dataFilePath);
        List<TreeNode> listtree=lcaTool.getTreeNodeList();

        CreateTreeNode createTreeNode=new CreateTreeNode();
        TreeNode root=listtree.get(0);
        listtree.remove(0);
        createTreeNode.CreateTreeNodeInsert(root,listtree);

        //生成已经构建好的数据结构
       TreeNode treeNode=createTreeNode.getTreeNode();


        TreeNode A = new TreeNode("A");
        TreeNode B = new TreeNode("B");
        TreeNode C = new TreeNode("C");
        TreeNode D = new TreeNode("D");
        TreeNode E = new TreeNode("E");
        TreeNode F = new TreeNode("F");
        TreeNode H = new TreeNode("H");
        A.addNode(B);
        A.addNode(C);
        B.addNode(D);
        B.addNode(E);
        C.addNode(F);
        D.addNode(H);
        TranvesalTreeNodeTool tranvesalTreeNodeTool = new TranvesalTreeNodeTool();
        tranvesalTreeNodeTool.deepFirstSearch(treeNode);
        TranvesalTreeNodeTool.printPath(tranvesalTreeNodeTool.getRootToNodePath("HCoV-OC43"));
        TranvesalTreeNodeTool.printPath(tranvesalTreeNodeTool.getRootToNodePath("Hcov-229E"));
        TreeNode x = tranvesalTreeNodeTool.getLeastParentNode(tranvesalTreeNodeTool.getRootToNodePath("HCoV-OC43"), tranvesalTreeNodeTool.getRootToNodePath("Hcov-229E"));
        System.out.println(String.format("获取以上HCoV-OC43和Hcov-229E两个参数的距离%s共同祖先是:%s",x.getChildLst().size(),x.getNodeName()));


        TreeNode x1 = tranvesalTreeNodeTool.getLeastParentNode(tranvesalTreeNodeTool.getRootToNodePath("SARS-CoV"), tranvesalTreeNodeTool.getRootToNodePath("Zika virus"));
        System.out.println(String.format("获取以上SARS-CoV和Zika virus两个参数的距离%s共同祖先是:%s",x1.getChildLst().size(),x1.getNodeName()));

    }
}
